﻿Public Class MuonTra_DAL
    Dim cn As New ConnectDB()
    Public Function xacnhanMuon(ByVal p As MuonTra_DTO)
        Dim Nparameter As Integer = 1
        Dim name As String() = New String(Nparameter - 1) {}
        Dim value As Object() = New Object(Nparameter - 1) {}

        name(0) = "id_sach"
        value(0) = p._idsach

        Return cn.loadData("xacnhanmuon", name, value, Nparameter)
    End Function
    Public Function loadSachduocmuon() As DataTable
        Return cn.loadData("load_sachdemuon")
    End Function
    Public Function loadInfoDocGiaMuon(ByVal p As MuonTra_DTO) As DataTable
        Dim Nparameter As Integer = 1
        Dim name As String() = New String(Nparameter - 1) {}
        Dim value As Object() = New Object(Nparameter - 1) {}

        name(0) = "taikhoan"
        value(0) = p.taikhoan

        Return cn.loadData("load_docgiapopup", name, value, Nparameter)
    End Function
    Public Function themMuon(ByVal p As MuonTra_DTO) As DataTable
        Dim Nparameter As Integer = 7
        Dim name As String() = New String(Nparameter - 1) {}
        Dim value As Object() = New Object(Nparameter - 1) {}

        name(0) = "taikhoan"
        value(0) = p.taikhoan

        name(1) = "tennv"
        value(1) = p._tennvmuon

        name(2) = "kieumuon"
        value(2) = p._kieumuon

        name(3) = "ngaytra"
        value(3) = p._ngaytra

        name(4) = "ngaymuon"
        value(4) = p.ngaymuon

        name(5) = "id_sach"
        value(5) = p._idsach

        name(6) = "sosach"
        value(6) = p._soluongsach

        Return cn.loadData("themmuon", name, value, Nparameter)
    End Function
    Public Function loadSachDocGiaMuon(ByVal p As MuonTra_DTO)
        Dim Nparameter As Integer = 1
        Dim name As String() = New String(Nparameter - 1) {}
        Dim value As Object() = New Object(Nparameter - 1) {}

        name(0) = "taikhoan"
        value(0) = p.taikhoan

        Return cn.loadData("load_sachdocgiamuon", name, value, Nparameter)
    End Function
    Public Function loadThongTinTraPopup(ByVal p As MuonTra_DTO)
        Dim Nparameter As Integer = 3
        Dim name As String() = New String(Nparameter - 1) {}
        Dim value As Object() = New Object(Nparameter - 1) {}

        name(0) = "taikhoan"
        value(0) = p.taikhoan

        name(1) = "id_sach"
        value(1) = p._idsach

        name(2) = "ngaytra"
        value(2) = p._ngaytra

        Return cn.loadData("load_thongtintrapopup", name, value, Nparameter)
    End Function

    Public Function loadDsMuon() As DataTable
        Return cn.loadData("load_danhsachmuon")
    End Function
    Public Function themTra(ByVal dt As DataTable)
        Return cn.insertBulkData("themtra", dt, "@themtra")
    End Function
    Public Function capnhapMuon(ByVal p As MuonTra_DTO)
        Dim Nparameter As Integer = 9
        Dim name As String() = New String(Nparameter - 1) {}
        Dim value As Object() = New Object(Nparameter - 1) {}

        name(0) = "id_sach"
        value(0) = p._idsach

        name(1) = "taikhoan"
        value(1) = p._taikhoan

        name(2) = "tennv"
        value(2) = p._tennvmuon

        name(3) = "ngaytra"
        value(3) = p._ngaytra

        name(4) = "ngaytracu"
        value(4) = p._ngaytracu

        name(5) = "ngaymuoncu"
        value(5) = p._ngaymuoncu

        name(6) = "ngaymuon"
        value(6) = p._ngaymuon

        name(7) = "kieumuon"
        value(7) = p._kieumuon

        name(8) = "kieumuoncu"
        value(8) = p._kieumuoncu
        Return cn.loadData("capnhatmuon", name, value, Nparameter)
    End Function

    Public Function xoaMuon(ByVal p As MuonTra_DTO)
        Dim Nparameter As Integer = 6
        Dim name As String() = New String(Nparameter - 1) {}
        Dim value As Object() = New Object(Nparameter - 1) {}

        name(0) = "id_sach"
        value(0) = p._idsach

        name(1) = "taikhoan"
        value(1) = p._taikhoan

        name(2) = "tennv"
        value(2) = p._tennvmuon

        name(3) = "ngaytra"
        value(3) = p._ngaytra

        name(4) = "ngaymuon"
        value(4) = p._ngaymuon

        name(5) = "kieumuon"
        value(5) = p._kieumuon

        Return cn.loadData("xoamuon", name, value, Nparameter)
    End Function
    Public Function loadDocGiaTra() As DataTable
        Return cn.loadData("load_docgiatra")
    End Function
    Public Function thongkeMuonTheoDM() As DataTable
        Return cn.loadData("thongkemuon_danhmuc")
    End Function
    Public Function thongkeMuonTheoThang() As DataTable
        Return cn.loadData("thongkemuon_thang")
    End Function
    Public Function themMuonTuDocGia(ByVal p As MuonTra_DTO)
        Dim Nparameter As Integer = 6
        Dim name As String() = New String(Nparameter - 1) {}
        Dim value As Object() = New Object(Nparameter - 1) {}

        name(0) = "id_sach"
        value(0) = p.id_sach

        name(1) = "taikhoan"
        value(1) = p._taikhoan

        name(2) = "ngaytra"
        value(2) = p._ngaytra

        name(3) = "kieumuon"
        value(3) = p._kieumuon

        name(4) = "soluong"
        value(4) = p.soluongsach

        name(5) = "tensach"
        value(5) = p.tensach
        Return cn.loadData("themdscho", name, value, Nparameter)
    End Function
    Public Function loadDSChoMuon() As DataTable
        Return cn.loadData("load_dscho")
    End Function
    Public Function xoaDSChoMuon(ByVal p As MuonTra_DTO)
        Dim Nparameter As Integer = 2
        Dim name As String() = New String(Nparameter - 1) {}
        Dim value As Object() = New Object(Nparameter - 1) {}

        name(0) = "id_sach"
        value(0) = p.id_sach

        name(1) = "taikhoan"
        value(1) = p._taikhoan

        Return cn.loadData("xoacho", name, value, Nparameter)
    End Function
    Public Function themMuonTuDSCho(ByVal p As MuonTra_DTO)
        Dim Nparameter As Integer = 6
        Dim name As String() = New String(Nparameter - 1) {}
        Dim value As Object() = New Object(Nparameter - 1) {}

        name(0) = "id_sach"
        value(0) = p._idsach

        name(1) = "taikhoan"
        value(1) = p._taikhoan

        name(2) = "tennv"
        value(2) = p._tennvmuon

        name(3) = "ngaytra"
        value(3) = p._ngaytra

        name(4) = "ngaymuon"
        value(4) = p._ngaymuon

        name(5) = "kieumuon"
        value(5) = p._kieumuon

        Return cn.loadData("themmuon_dscho", name, value, Nparameter)
    End Function
    Public Function loadLichSuMuonDocGia(ByVal p As MuonTra_DTO)
        Dim Nparameter As Integer = 1
        Dim name As String() = New String(Nparameter - 1) {}
        Dim value As Object() = New Object(Nparameter - 1) {}

        name(0) = "taikhoan"
        value(0) = p._taikhoan

        Return cn.loadData("load_ghichudocgia", name, value, Nparameter)
    End Function
End Class
